﻿using System;
using System.Collections.Generic;
using System.Text;
using DepInnerTask.Common.Interface;
using DepInnerTask.Common.Entity;
using IBatisNet.DataMapper;
using Common.Service;
using System.Collections;
using Common.Logging;
using DepInner;
namespace DepInnerTask.Logic
{
    class TasksLogic:ITasks
    {
         public IList GetList(string where, int start, int limit, out int count)
        {
            Hashtable table = new Hashtable();
            //查询条件的形式 为 [表字段名=参数值; ...]
            if (!String.IsNullOrEmpty(where))
            {
                where = where.TrimEnd('△');//格式化 条件 语句
                string[] strWheres = where.Split('△');//
                for (int i = 0; i < strWheres.Length; i++)
                {
                    string str = strWheres[i];
                    string[] strParems = str.Split('▽');
                    table.Add(strParems[0], strParems[1]);//参数 将参数信息添加到hashtable中
                }
            }
            //table.Add("PROCESSNAME", "ss");
            string ss = DataHelper.Instance().GetSqlString("GetTasksListByID", table);
           
            IList list = DataHelper.Instance().GetList("GetTasksListByID", table, start, limit);
             count = list.Count;

            return list;
        }
         public IList GetList()
         {
             Hashtable table = new Hashtable();
             IList list = DataHelper.Instance().GetList("GetAllTasks", table);           
             return list;
         }
        public TasksEntity Get(string taskId)
        {
            return DataHelper.Instance().Get<TasksEntity>("Task_GetListByID", taskId);
        }

        public void Insert(TasksEntity entity)
        {
            DataHelper.Instance().Insert("InsertTasks", entity);
        }

        public void Update(TasksEntity entity)
        {
            DataHelper.Instance().Update("TaskLogic_Update", entity);
        }

        public bool Exists(string taskId)
        {
            throw new NotImplementedException();
        }

        public void Delete(string taskId)
        {
            DataHelper.Instance().Delete("DeleteTasksByID", taskId);
        }

    }
    }

